import { CoreInterface } from '../../wasm/pkg/core_wasm';

export class WasmLoader {
    private instance?: CoreInterface;

    async initialize() {
        try {
            const wasm = await import('../../wasm/pkg/core_wasm');
            this.instance = new wasm.CoreInterface();
            return true;
        } catch (err) {
            console.error('WASM initialization failed:', err);
            return false;
        }
    }

    execute(command: string): Promise<any> {
        if (!this.instance) {
            throw new Error('WASM module not initialized');
        }
        return Promise.resolve(this.instance.execute(command));
    }

    loadAdapter(adapterType: string): Promise<any> {
        if (!this.instance) {
            throw new Error('WASM module not initialized');
        }
        return Promise.resolve(this.instance.load_adapter(adapterType));
    }
}